﻿using Coldairarrow.Business.Base_bankcode;
using Coldairarrow.Entity.Base_bankcode;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_bankcode
{
    /// <summary>
    /// 代发通道控制器
    /// </summary>
    [Route("/Base_bankcode/[controller]/[action]")]
    [OpenApiTag("代发通道控制器")]
    public class bankcodeController : BaseApiController
    {
        #region DI

        public bankcodeController(IbankcodeBusiness bankcodeBus)
        {
            _bankcodeBus = bankcodeBus;
        }

        IbankcodeBusiness _bankcodeBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<bankcode>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _bankcodeBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<bankcode> GetTheData(IdInputDTO input)
        {
            return await _bankcodeBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(bankcode data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _bankcodeBus.AddDataAsync(data);
            }
            else
            {
                await _bankcodeBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        [ApiPermission("bankcode.Delete")]
        public async Task DeleteData(List<string> ids)
        {
            await _bankcodeBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}